﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Assignment1
{
    public enum BlockType
    {
        WALL= 0,
        TERRAIN=1,
        GOAL=5,
        START=3,
        VISITED=2,
        PATH=4,
    }
    public struct Position
    {
        public int x, y;
        public Position(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
    }
    class MapInfo
    {
        private List<List<BlockType>> mapData;

        public List<List<BlockType>> MapData
        {
            get
            { 
                return mapData;
            }
        }
        
        
        private Position startPos;
        /// <summary>
        /// Start position
        /// </summary>
        public Position StartPos
        {
            get { return startPos; }
            set { startPos = value; }
        }

        private Position goalSpot;
        /// <summary>
        /// Goal Position
        /// </summary>
        public Position GoalSpot
        {
            get { return goalSpot; }
            set { goalSpot = value; }
        }

        private int maxHeight;
        /// <summary>
        /// Map Height
        /// </summary>
        public int MaxHeight
        {
            get { return maxHeight; }
            set { maxHeight = value; }
        }
        
        private int maxWidth;
        /// <summary>
        /// Map Width
        /// </summary>
        public int MaxWidth
        {
            get { return maxWidth; }
            set { maxWidth = value; }
        }

        public MapInfo()
        {
            mapData = new List<List<BlockType>>();
            maxHeight = 0;
            maxWidth = 0;
        }

        public void setMap(int x, int y, BlockType value)
        {
            mapData[y][x] = value;
        }

        public void addRow(List<BlockType> row)
        {
            mapData.Add(row);
        }

        public BlockType getMap(int x, int y)
        {
            return mapData[y][x];
        }
        public string ToString()
        {
            StringBuilder sb = new StringBuilder();
            foreach (List<BlockType> lst in mapData)
            {
                foreach (BlockType bt in lst)
                {
                    sb.Append((int)bt + " ");
                }
                sb.Remove(sb.Length - 1, 1);
                sb.AppendLine("");
            }
            return sb.ToString();
        }
    }
}
